package com.k.base.jdk.functions.demo6;

import com.k.base.jdk.functions.demo5.model.Fei;
import com.k.base.jdk.functions.demo5.model.Gan;
import com.k.base.jdk.functions.demo5.model.Heart;
import com.k.util.StringUtils;

public abstract class AbstractPerson implements IPerson {
    abstract Heart getHeart();
    abstract Gan getGan();
    abstract Fei getFei();
    public boolean isPerson(){
        String myHeartCode = getHeart().getHeartCode();
        String myGanCode = getGan().getGanCode();
        String myFeiCode = getFei().getFeiCode();
        if(StringUtils.isBlank(myHeartCode)){
            throw new IllegalArgumentException("Loose heart");
        }
        if(StringUtils.isBlank(myGanCode)){
            throw new IllegalArgumentException("Loose gan");
        }
        if(StringUtils.isBlank(myFeiCode)){
            throw new IllegalArgumentException("Loose fei");
        }
        return true;
    }

    @Override
    public void gen() {
        if(!isPerson()){
            System.out.println("this is not person");
            return;
        }
        String personCode = getHeart().getHeartCode()+"-"+getGan().getGanCode()+"-"+getFei().getFeiCode();
        System.out.println("personCode:"+personCode);
    }
}
